<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var t = async_test("Test the case where an ImageBitmap produced on a worker is consumed on another worker");

var worker1 = new Worker('OffscreenCanvas-ImageBitmap-worker-to-worker-1.js');
var worker2 = new Worker('OffscreenCanvas-ImageBitmap-worker-to-worker-2.js');

worker1.addEventListener('message', msg => {
  worker2.postMessage(msg.data, [msg.data]);
});

worker2.addEventListener('message', t.step_func(function(msg) {
  var testCtx = document.createElement('canvas').getContext('2d');
  testCtx.drawImage(msg.data, 0, 0);
  var pixelData = testCtx.getImageData(0, 0, 1, 1);
  assert_equals(pixelData.data[0], 0, "red");
  assert_equals(pixelData.data[1], 255, "green");
  assert_equals(pixelData.data[2], 0, "blue");
  assert_equals(pixelData.data[3], 255, "alpha");
  t.done();
}));

worker1.postMessage("go");

</script>

